﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestPicture
{
	public partial class Form1 : Form
	{
		private string[] pic={"one","two","three"};
		private string CoFile;
		private string[] PartList;
		private string[] PartChineseList;
		private bool ShowPic;
		
		public Form1()
		{
			InitializeComponent();
		}
		
		public PictureBox GetPictureBox(string name)
		{
			object o = this.GetType().GetField(name, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase).GetValue(this);
			return ((PictureBox)o);
		}

		public object GetObject(string name)
		{
			object o = this.GetType().GetField(name, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase).GetValue(this);
			return o;
		}



		private void button3_Click(object sender, EventArgs e)
		{
			var collection = this.Controls.OfType<UserControl>();
			foreach (var item in collection)
			{
				MessageBox.Show(item.Name);
				item.Dispose();
			}
			var userControl = new UserControlOne();
			userControl.Location = new System.Drawing.Point(320, 62);
			this.Controls.Add(userControl);
		}

		private void button4_Click(object sender, EventArgs e)
		{
			var collection = this.Controls.OfType<UserControl>();
			foreach (var item in collection)
			{
				MessageBox.Show(item.Name);
				item.Dispose();
			}
			var userControl = new UserControlThree();
			userControl.Location = new System.Drawing.Point(320, 62);
			this.Controls.Add(userControl);
		}

		private void one_MouseEnter(object sender, EventArgs e)
		{
			toolTip1.SetToolTip(one,"one");
			toolTip1.SetToolTip(two, "two");
		}

		private void toolTip1_Popup(object sender, PopupEventArgs e)
		{

		}
		
		private void ActivePart()
		{
		}
		private void ActiveTool()
		{
		}

		private void one_Click(object sender, EventArgs e)
		{
			
		}

		private void button5_Click(object sender, EventArgs e)
		{
			TestClass.ChangeTextBox(textBox1);
		}

		private void button6_Click(object sender, EventArgs e)
		{
			CommonClass.LoadPartName(System.IO.Directory.GetCurrentDirectory() + "\\..\\..\\pzwj.txt");
		}

		private void axShockwaveFlash1_Enter(object sender, EventArgs e)
		{
		}

		private void three_Click(object sender, EventArgs e)
		{
			CommonClass.ActiveTool(((PictureBox)sender).Name, axCult3DP1);
		}

		private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
		{
			if(((ComboBox)sender).SelectedIndex==0)
			{
				hidden.Enabled=false;
				transparent.Enabled=false;
			}
			else
			{
				hidden.Enabled=true;
				transparent.Enabled=true;
			}
		}

		private void hidden_Click(object sender, EventArgs e)
		{
			axCult3DP1.TriggerAction("hidden", PartList[comboBox1.SelectedIndex]);
		}

		private void transparant_Click(object sender, EventArgs e)
		{
			axCult3DP1.TriggerAction("transparant", PartList[comboBox1.SelectedIndex]);
		}

		private void textBox2_TextChanged(object sender, EventArgs e)
		{

		}

		private void button1_Click(object sender, EventArgs e)
		{
			textBox2.Text=CommonClass.ToUnicode("TIPS: "+textBox1.Text);
		}
				
		/*
		 * 需要完成的部分
		 * 1.获取所有的图片的名字（从txt文件读入，并转为程序中的常量）
		 * 2.初始化所有工具的名字（手工输入为程序中的常量）
		 * 3.检查所有图片和工具是否存在（根据 System.NullReferenceException 异常来进行判断）
		 * 4.对于分解模块，所有的工具添加一个鼠标事件，给co文件发送一个消息（工具事件调用 ActiveTool(***.Name)    ）
		 * 5.对于结合模块，所有的零件和工具添加一个鼠标事件，给co文件发送一个消息（零件事件调用ActivePart(***.Name)     ）
		 * 6.提示窗口命名规范（使用RichTextBox控件，命名为result）
		 * 
		 * 
		*/
	}
}
